package manage.util.excel;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class SheetObject {
	private final String name;
	private final List<SheetRow> rows;
	private List<Integer[]> mergeCells;
	public SheetObject(String name){
		this(name,new SheetRow[]{});
	}
	/**
	 * 
	 *  rows
	 *  name
	 */
	public SheetObject(String name,SheetRow... rows){
		this.rows= new ArrayList<>();
		this.rows.addAll(Arrays.asList(rows));
		this.name=name;
		this.mergeCells= new ArrayList<>();
	}
	public SheetObject addRow(SheetRow... sr) {
		this.rows.addAll(Arrays.asList(sr));
		return this;
	}
	/**
	 * 设置合并单元格  
	 * int[][]{
	 * 	int[]{从行,到行,从列,到列}
	 * }
	 */
	public SheetObject setMergeCells(Integer[][] mcs) {
		this.mergeCells= new ArrayList<>();
		this.mergeCells.addAll(Arrays.asList(mcs));
		return this;
	}
	public SheetObject setMergeCells(List<Integer[]> mcs) {
		this.mergeCells=mcs;
		return this;
	}
	/**
	 * 添加合并单元格  int[]{从行,到行,从列,到列}
	 *  nc
	 * 
	 */
	public SheetObject addMergeCells(Integer[] nc) {
		this.mergeCells.add(nc);
		return this;
	}
	
	public String getName() {
		return name;
	}
	public List<SheetRow> getRowList(){
		return rows;
	}
	public SheetRow[] getRows() {
		return rows.toArray(new SheetRow[] {});
	}
	public List<Integer[]> getMergeCells() {
		return this.mergeCells;
	}
}
